/* Groepje WC
 */

#define nSensors 4


int ledPin = 13;               
int value[nSensors];
int statePin = LOW;
int THRESHOLD = 320;

void setup() {
  pinMode(ledPin, OUTPUT); 
  Serial.begin(9600);
}

void loop() {
  //if(Serial.available() > 0 && Serial.read() == 'r')
  //{ 

  // Binnenhalen Piezos data  
  for(int i=0;i<nSensors;i++)
  {
    value[i] = analogRead(i);
  }

  // Interpeteren Piezos data
  int resultaat = -1; 
  int maxlezing = 0; 

  for(int i=0;i<nSensors;i++) 
  {  
    if   ((value[i] >= THRESHOLD) && (value[i] > maxlezing))
    { 
      maxlezing = value[i];
      resultaat = i;
    }
  } 
  if (resultaat >= 0) {
    Serial.print(resultaat);
    Serial.print(",");
    Serial.println(maxlezing);  
    delay(100);  // te veel data in serial poort
  }


}


